#ifndef BFSCLASS_H
#define BFSCLASS_H

#include <QThread>
#include <QRunnable>
#include "algraph.h"
#include "PolygonWidget.h"
#include <QDebug>
#include "widget.h"
#include "ui_widget.h"
class BFSClass : public QRunnable
{
public:
    BFSClass(ALGraph<int> *alg,PolygonWidget *pw,Widget *w):alg(alg),pw(pw),w(w){}
    void run() override{
        w->ui->listWidget->clear();
        alg->BFSTraverse([&](ALGraph<int>::VNode *node){
            qDebug()<<node->data;
            pw->currentnode=alg->GetIndex(node);
            //emit adddata(1);
            w->ui->listWidget->addItem(QString::number(node->data));
            w->myupdate();
            QThread::sleep(1);
        });
    }
public:
    Widget *w;
    PolygonWidget *pw;
    ALGraph<int> *alg;
signals:
    void adddata(int data);
};

#endif // BFSCLASS_H
